import request from '@/utils/request'

export const getEmployeeList = (params) => {
  return request.get('/sys/user', { params })
}

export const downLoadFileAPI = () => {
  return request.get(`/sys/user/export`, { responseType: 'blob' })
}

export function getExportTemplate() {
  return request({
    url: '/sys/user/import/template',
    responseType: 'blob' // 二进制文件流
  })
}

export const upLoadFileAPI = (data) => {
  return request.post('/sys/user/import', data)
}

export const delEmployeeAPI = (id) => {
  return request.delete(`/sys/user/${id}`)
}

export const addEmployeeAPI = (data) => {
  return request.post('/sys/user', data)
}

/**
 *  获取员工详情
 * **/

export function getEmployeeDetailAPI(id) {
  return request({
    url: `/sys/user/${id}`
  })
}

// 编辑员工详情
export function updateEmployeeDetailAPI(data) {
  return request({
    url: `/sys/user/${data.id}`,
    method: 'put',
    data
  })
}

/**
 * 获取可用的角色
 * **/

export function getEnableRoleListAPI() {
  return request({
    url: '/sys/role/list/enabled'
  })
}

/**
 * 分配员工角色
 * ***/

export function assignRoleAPI(data) {
  return request({
    url: '/sys/user/assignRoles',
    method: 'put',
    data
  })
}
